package com.mingye.listener;

import com.mingye.board.Board;
import com.mingye.components.GameFrame;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * 游戏重新开始监听器
 *
 * @author daixinyi
 */
public class ResetClickListener implements ActionListener {

    private GameFrame gameFrame;

    public ResetClickListener(GameFrame gameFrame) {
        this.gameFrame = gameFrame;
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        // 设置通关标志为false
        gameFrame.setVictoryFlag(false);
        // 已过关文字去除
        JLabel winInfoLabel = gameFrame.getOperationPanel().getWinInfoLabel();
        winInfoLabel.setText("");
        // 重新初始化面板
        Board board = gameFrame.getBoardPanel().getBoard();
        board.setFinishBoxCount(0);
        board.initBoard();

        gameFrame.getBoardPanel().repaint();

    }
}
